<script setup>
// 使用import方式引入图片，确保路径正确
import videoPlaceholder from '@/assets/images/videoInfo.png';

const videoSources = [
  { id: 1, name: '设备1', src: videoPlaceholder },
  { id: 2, name: '设备2', src: videoPlaceholder },
  { id: 3, name: '设备3', src: videoPlaceholder },
  { id: 4, name: '设备4', src: videoPlaceholder },
  { id: 5, name: '设备5', src: videoPlaceholder },
  { id: 6, name: '设备6', src: videoPlaceholder },
  { id: 7, name: '设备7', src: videoPlaceholder },
  { id: 8, name: '设备9', src: videoPlaceholder },
  { id: 8, name: '设备10', src: videoPlaceholder },
  { id: 8, name: '设备11', src: videoPlaceholder },
  { id: 8, name: '设备12', src: videoPlaceholder },
  { id: 8, name: '设备13', src: videoPlaceholder },
];
</script>

<template>
  <el-col :span="7" class="video-panel">
    <!-- 上部视频网格 (2行4列) -->
    <div class="video-grid">
      <div v-for="video in videoSources" :key="video.id" class="video-item">
        <img :src="video.src" :alt="video.name" class="video-thumbnail">
        <div class="video-label">{{ video.name }}</div>
      </div>
    </div>

    <!-- 下部数据展示区 -->
    <div class="data-display">
      <div class="sensor-data">
        <div class="data-grid">
          <div class="data-item">
            <div class="data-label">土壤湿度</div>
            <div class="data-value">62%</div>
          </div>
          <div class="data-item">
            <div class="data-label">空气温度</div>
            <div class="data-value">24℃</div>
          </div>
          <div class="data-item">
            <div class="data-label">光照强度</div>
            <div class="data-value">8500 Lux</div>
          </div>
          <div class="data-item">
            <div class="data-label">CO2浓度</div>
            <div class="data-value">420 ppm</div>
          </div>
        </div>
      </div>
    </div>
  </el-col>
</template>

<style scoped lang="less">
.video-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  border: 1px solid #e0e0e0;
  background-color: #f5f5f5;
}

.video-grid {
  display: flex;
  flex-wrap: wrap;
  height: 60%;
  background-color: #000;

  .video-item {
    max-width: 25%;
    aspect-ratio: 4/3; //
    border: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background-color: #fafafa;

    &:hover {
      background-color: rgba(0, 0, 0, 0.05);
      transform: scale(1.02);
      z-index: 1;
      box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
    }
  }

  .video-thumbnail {
    width: 100%;
    height: 80%;
    object-fit: cover;
    filter: grayscale(30%);
  }

  .video-label {
    height: 20%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    background-color: #eee;
    color: #333;
    border-top: 1px solid #e0e0e0;
  }
}

.data-display {
  height: 40%;
  padding: 15px;
  background-color: #000;
  border-top: 1px solid #e0e0e0;

  h3 {
    margin: 0 0 15px 0;
    color: #333;
    text-align: center;
    font-weight: 500;
    letter-spacing: 1px;
  }

  .data-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .data-item {
    flex: 1 0 calc(50% - 12px);
    background-color: #f9f9f9;
    border-radius: 4px;
    padding: 12px;
    text-align: center;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;

    &:hover {
      background-color: #f0f0f0;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    }

    .data-label {
      font-size: 12px;
      color: #666;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 4px;
    }

    .data-value {
      font-size: 16px;
      font-weight: 600;
      color: #222;
    }
  }
}
</style>